home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Main.bin / templates.jar / symantec / itools / wizards / JFCFrame / JAboutDialog.java next >
Text File  |  1998-10-22  |  4KB  |  136 lines

  1. /*
  2.         A basic implementation of the JDialog class.
  3. */
  4.  
  5. import java.awt.*;
  6. import com.sun.java.swing.*;
  7.  
  8. public class JAboutDialog extends com.sun.java.swing.JDialog
  9. {
  10.     public JAboutDialog(Frame parentFrame)
  11.     {
  12.         super(parentFrame);
  13.         // This code is automatically generated by Visual Cafe when you add
  14.         // components to the visual environment. It instantiates and initializes
  15.         // the components. To modify the code, only use code syntax that matches
  16.         // what Visual Cafe can generate, or Visual Cafe may be unable to back
  17.         // parse your Java file into its visual environment.
  18.         //{{INIT_CONTROLS
  19.         setTitle("JFC Application - About");
  20.         setModal(true);
  21.         getContentPane().setLayout(new GridBagLayout());
  22.         setSize(248,94);
  23.         setVisible(false);
  24.         okButton.setText("OK");
  25.         okButton.setActionCommand("OK");
  26.         okButton.setOpaque(false);
  27.         okButton.setMnemonic((int)'O');
  28.         getContentPane().add(okButton, new com.symantec.itools.awt.GridBagConstraintsD(2,1,1,1,0.0,0.0,java.awt.GridBagConstraints.CENTER,java.awt.GridBagConstraints.NONE,new Insets(0,0,10,0),0,0));
  29.         okButton.setBounds(98,59,51,25);
  30.         aboutLabel.setHorizontalAlignment(com.sun.java.swing.SwingConstants.CENTER);
  31.         aboutLabel.setText("A JFC Application");
  32.         getContentPane().add(aboutLabel, new com.symantec.itools.awt.GridBagConstraintsD(0,0,3,1,1.0,1.0,java.awt.GridBagConstraints.CENTER,java.awt.GridBagConstraints.BOTH,new Insets(0,0,0,0),0,0));
  33.         aboutLabel.setBounds(0,0,248,59);
  34.         //}}
  35.  
  36.         //{{REGISTER_LISTENERS
  37.         SymWindow aSymWindow = new SymWindow();
  38.         this.addWindowListener(aSymWindow);
  39.         SymAction lSymAction = new SymAction();
  40.         okButton.addActionListener(lSymAction);
  41.         //}}
  42.     }
  43.  
  44.     public void setVisible(boolean b)
  45.     {
  46.         if (b)
  47.         {
  48.             Rectangle bounds = (getParent()).getBounds();
  49.             Dimension size = getSize();
  50.             setLocation(bounds.x + (bounds.width - size.width)/2,
  51.                         bounds.y + (bounds.height - size.height)/2);
  52.         }
  53.  
  54.         super.setVisible(b);
  55.     }
  56.  
  57.     public void addNotify()
  58.     {
  59.         // Record the size of the window prior to calling parents addNotify.
  60.         Dimension d = getSize();
  61.  
  62.         super.addNotify();
  63.  
  64.         if (fComponentsAdjusted)
  65.             return;
  66.         // Adjust components according to the insets
  67.         Insets insets = getInsets();
  68.         setSize(insets.left + insets.right + d.width, insets.top + insets.bottom + d.height);
  69.         Component components[] = getContentPane().getComponents();
  70.         for (int i = 0; i < components.length; i++)
  71.         {
  72.             Point p = components[i].getLocation();
  73.             p.translate(insets.left, insets.top);
  74.             components[i].setLocation(p);
  75.         }
  76.         fComponentsAdjusted = true;
  77.     }
  78.  
  79.     // Used for addNotify check.
  80.     boolean fComponentsAdjusted = false;
  81.  
  82.     //{{DECLARE_CONTROLS
  83.     com.sun.java.swing.JButton okButton = new com.sun.java.swing.JButton();
  84.     com.sun.java.swing.JLabel aboutLabel = new com.sun.java.swing.JLabel();
  85.     //}}
  86.  
  87.     class SymWindow extends java.awt.event.WindowAdapter
  88.     {
  89.         public void windowClosing(java.awt.event.WindowEvent event)
  90.         {
  91.             Object object = event.getSource();
  92.             if (object == JAboutDialog.this)
  93.                 jAboutDialog_windowClosing(event);
  94.         }
  95.     }
  96.  
  97.     void jAboutDialog_windowClosing(java.awt.event.WindowEvent event)
  98.     {
  99.         // to do: code goes here.
  100.              
  101.         jAboutDialog_windowClosing_Interaction1(event);
  102.     }
  103.  
  104.     void jAboutDialog_windowClosing_Interaction1(java.awt.event.WindowEvent event) {
  105.         try {
  106.             // JAboutDialog Hide the JAboutDialog
  107.             this.setVisible(false);
  108.         } catch (Exception e) {
  109.         }
  110.     }
  111.     
  112.     class SymAction implements java.awt.event.ActionListener
  113.     {
  114.         public void actionPerformed(java.awt.event.ActionEvent event)
  115.         {
  116.             Object object = event.getSource();
  117.             if (object == okButton)
  118.                 okButton_actionPerformed(event);
  119.         }
  120.     }
  121.  
  122.     void okButton_actionPerformed(java.awt.event.ActionEvent event)
  123.     {
  124.         // to do: code goes here.
  125.              
  126.         okButton_actionPerformed_Interaction1(event);
  127.     }
  128.  
  129.     void okButton_actionPerformed_Interaction1(java.awt.event.ActionEvent event) {
  130.         try {
  131.             // JAboutDialog Hide the JAboutDialog
  132.             this.setVisible(false);
  133.         } catch (Exception e) {
  134.         }
  135.     }
  136. }